import 'dart:convert' show json;

import 'category_mode.dart';

T asT<T>(dynamic value) {
  if (value is T) {
    return value;
  }
  return null;
}

class CategoryList {
  CategoryList({
    this.results,
  });

  factory CategoryList.fromJson(Map<String, dynamic> jsonRes) {
    if (jsonRes == null) {
      return null;
    }

    final List<Category> results =
    jsonRes['results'] is List ? <Category>[] : null;
    if (results != null) {
      for (final dynamic item in jsonRes['results']) {
        if (item != null) {
          results.add(Category.fromJson(asT<Map<String, dynamic>>(item)));
        }
      }
    }
    return CategoryList(
      results: results,
    );
  }

  List<Category> results;

  Map<String, dynamic> toJson() => <String, dynamic>{
    'results': results,
  };
  @override
  String toString() {
    return json.encode(this);
  }
}


